﻿public  class GlobalMembersGame_action: GlobalMembersGame_object
{
	// ****************************************************************************
	// * Punch And Kick -- a simple 2D Fighting Game.
	// *
	// * Copyright (C) 2013 by
	// * Liu Chao
	// *
	// * This file is part of the Punch And Kick project, and may only be used,
	// * modified, and distributed under the terms of the GPLv2.
	// *
	// * (GPLv2 is abbreviation of GNU General Public License Version 2)
	// *
	// * By continuing to use, modify, or distribute this file you indicate that you
	// * have read the license and understand and accept it fully.
	// *
	// * The Punch And Kick project is distributed in the hope that it will be
	// * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
	// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GPL v2 for
	// * more details.
	// *
	// * You should have received a copy of the GPLv2 along with this file. It is
	// * usually in the LICENSE.TXT file, If not, see <http://www.gnu.org/licenses/>.
	// * **************************************************************************

	// ****************************************************************************
	// * Punch And Kick -- 一个普通的2D格斗游戏
	// *
	// * 版权所有 (C) 2013 归属于
	// * 刘超
	// *
	// * 这个文件是 Punch And Kick 项目的一部分，并且只可以根据GPLv2许可协议来使用、
	// * 更改和发布。
	// *
	// * (GPLv2 是 GNU通用公共许可证第二版 的英文缩写)
	// *
	// * 继续使用、修改或发布本文件，表明您已经阅读并完全理解和接受这个许可协议。
	// *
	// * Punch And Kick 项目是基于技术交流目的而加以散布的，但不负任何担保责任，例
	// * 如：稳定性、可玩性、趣味性等的担保，甚至没有适销性或特定用途的隐含担保，详
	// * 情请参照GPLv2许可协议。
	// *
	// * 您应已收到附随于本文件的GPLv2许可协议的副本，它通常在LICENSE.TXT文件中，如果
	// * 没有，请查看：<http://www.gnu.org/licenses/>.
	// * **************************************************************************


	//* 载入角色的动作动画资源 
	internal static ActionData_ __ActionRes_Load(ActionInfo_[] action_set, string class_name, int n_max, int action_type)
	{
		int i;
		int j;
		ActionData_ action;
		LCUI_Graph_ p_graph;
		LCUI_Graph_ graph_buff = null;
		LCUI_Graph_ tmp_graph = null;

		action = Action_Create();
		// 在动作数据集里查找指定动作的数据 
		for(i =0; i<n_max; ++i)
		{
			if(action_set[i].action_type == action_type)
			{
				break;
			}
		}
		// 未找到则退出 
		if(i >= n_max)
		{
			return null;
		}
		// 设置该动作是否重复播放 
		Action_SetReplay(action, action_set[i].replay);
		for(j =0; j<DefineConstantsGame_action.MAX_FRAME_NUM; ++j)
		{
			if(action_set[i].frame.Length <=j||!action_set[i].frame[j].enable)
			{
				break;
			}
			MyGraph.Graph_Init(out graph_buff);
			// 获取动作图资源 
			MyGraph.GameGraphRes_GetGraph(class_name, action_set[i].frame[j].graph_name, graph_buff);
			// 若需要水平翻转 
			if(action_set[i].frame[j].horiz_flip)
			{
				MyGraph.Graph_Init(out tmp_graph);
				tmp_graph.color_type = graph_buff.color_type;
				MyGraph.Graph_HorizFlip(graph_buff, tmp_graph);
				p_graph = tmp_graph;
			}
			else
			{
				p_graph = graph_buff;
			}
			// 添加一帧动作 
			Action_AddFrame(action, action_set[i].frame[j].offset_x, action_set[i].frame[j].offset_y, p_graph, action_set[i].frame[j].remain_time);
			// 设置受攻击范围 
			Action_SetHitRange(action, j, action_set[i].frame[j].hit);
			// 设置攻击范围 
			Action_SetAttackRange(action, j, action_set[i].frame[j].atk);
			// 设置该帧动作是否产生新攻击 
			Action_SetNewAttack(action, j, action_set[i].frame[j].new_attack);
		}
		return action;
	}

	//* 载入指定角色的动作动画 
	public static ActionData_ ActionRes_Load(int role_id, int action_type)
	{
		int total_action;
	    ActionInfo_[] action_set;
		string class_name;

		switch((RoleID)role_id)
		{
		case RoleID.ROLE_KUNIO:
			total_action = GlobalMembersGameres_kunio.ActionRes_Kunio_GetActionTotalNum();
			action_set = GlobalMembersGameres_kunio.ActionRes_Kunio_GetActionSet();
			class_name = DefineConstantsGame_action.ACTION_RES_CLASS_KUNI;
			break;
            case RoleID.ROLE_RIKI:
                total_action = GlobalMembersGameres_riki. ActionRes_Riki_GetActionTotalNum();
                action_set = GlobalMembersGameres_riki. ActionRes_Riki_GetActionSet();
                class_name = DefineConstantsGame_action.ACTION_RES_CLASS_RIKI;
                break;
            //case RoleID.ROLE_MIKE:
            //	total_action = ActionRes_Mike_GetActionTotalNum();
            //	action_set = ActionRes_Mike_GetActionSet();
            //	class_name = DefineConstantsGame_action.ACTION_RES_CLASS_MIKE;
            //	break;
            //case RoleID.ROLE_BEN:
            //	total_action = ActionRes_Ben_GetActionTotalNum();
            //	action_set = ActionRes_Ben_GetActionSet();
            //	class_name = DefineConstantsGame_action.ACTION_RES_CLASS_BEN;
            //	break;
            //case RoleID.ROLE_TORAJI:
            //	total_action = ActionRes_Toraji_GetActionTotalNum();
            //	action_set = ActionRes_Toraji_GetActionSet();
            //	class_name = DefineConstantsGame_action.ACTION_RES_CLASS_TORAJI;
            //	break;
            default:
			return null;
		}
		return __ActionRes_Load(action_set, class_name, total_action, action_type);
	}
}

public enum AIActionType
{
	ai_action_type_none,
	ai_action_type_wait,
	ai_action_type_run_close,   /**< 跑步靠近目标 */
	ai_action_type_walk_close,  /**< 步行靠近目标 */
	ai_action_type_run_away,    /**< 跑步远离目标 */
	ai_action_type_walk_away,   /**< 步行远离目标 */
	ai_action_type_observe,     /**< 观察目标 */
	ai_action_type_stop_run,    /**< 停止奔跑 */
	ai_action_type_a_attack,    /**< A攻击 */
	ai_action_type_b_attack,    /**< B攻击 */
	ai_action_type_jump,        /**< 跳跃 */
	ai_action_type_defense,     /**< 防御 */
	ai_action_type_stop_defense,    /**< 停止防御 */
	ai_action_type_down
};

public enum ActionType
{
	ACTION_START = 0,
	ACTION_READY,
	ACTION_STANCE,
	ACTION_WALK,
	ACTION_RUN,
	ACTION_A_ATTACK,
	ACTION_B_ATTACK,
	ACTION_DEFENSE,
	ACTION_SOLID_DEFENSE,
	ACTION_MACH_A_ATTACK,
	ACTION_MACH_B_ATTACK,
	ACTION_JUMP_MACH_A_ATTACK,
	ACTION_JUMP_MACH_B_ATTACK,
	ACTION_AS_ATTACK,
	ACTION_BS_ATTACK,
	ACTION_AJ_ATTACK,
	ACTION_BJ_ATTACK,
	ACTION_ASJ_ATTACK,
	ACTION_BSJ_ATTACK,
	ACTION_FINAL_BLOW,
	ACTION_FALL,
	ACTION_HIT,
	ACTION_HIT_FLY,
	ACTION_HIT_FLY_FALL,
	ACTION_LYING,
	ACTION_LYING_HIT,
	ACTION_TUMMY_HIT_FLY,
	ACTION_TUMMY,
	ACTION_TUMMY_HIT,
	ACTION_REST,
	ACTION_SQUAT,
	ACTION_JUMP,
	ACTION_F_ROLL,
	ACTION_ROLL_DOWN,   /**< 面朝上卷曲 */
	ACTION_ROLL_UP,     /**< 面朝下卷曲 */
	ACTION_B_ROLL,
	ACTION_JUMP_ELBOW,
	ACTION_JUMP_STOMP,
	ACTION_KICK,
	ACTION_GUILLOTINE,
	ACTION_SPINHIT,
	ACTION_BOMBKICK,
	ACTION_MACH_STOMP,
	ACTION_CATCH,
	ACTION_BE_CATCH,
	ACTION_BE_PUSH,
	ACTION_HALF_LYING,
	ACTION_HALF_STANCE,
	ACTION_BACK_BE_CATCH,
	ACTION_CATCH_SKILL_FA,  /**< 正面抓握压制技能 A */
	ACTION_CATCH_SKILL_FB,  /**< 正面抓握压制技能 B */
	ACTION_CATCH_SKILL_BA,  /**< 背面抓握压制技能 A */
	ACTION_CATCH_SKILL_BB,  /**< 背面抓握压制技能 B */
	ACTION_WEAK_RUN,
	ACTION_LIFT_STANCE,
	ACTION_LIFT_WALK,
	ACTION_LIFT_RUN,
	ACTION_LIFT_JUMP,
	ACTION_LIFT_FALL,
	ACTION_THROW,
	ACTION_RIDE,
	ACTION_RIDE_ATTACK,
	ACTION_LYING_DYING, /**< 躺着，快死了 */
	ACTION_TUMMY_DYING, /**< 趴着，快死了 */
	TOTAL_ACTION_NUM    /** 动作的总数量 */
};

public enum RoleID
{
	ROLE_KUNIO,
	ROLE_RIKI,
	ROLE_MIKE,
	ROLE_BEN,
	ROLE_TORAJI,
	TOTAL_ROLE_NUM
};

public struct ActionFrameInfo_
{
	public LCUI_BOOL enable;
	public LCUI_BOOL new_attack;
	public LCUI_BOOL horiz_flip;
	public string graph_name;
	public int remain_time;
	public int offset_x, offset_y;
	public RangeBox_ hit, atk;
    
    public ActionFrameInfo_(LCUI_BOOL enable, LCUI_BOOL new_attack, LCUI_BOOL horiz_flip, string graph_name, int remain_time, int offset_x, int offset_y, RangeBox_ hit, RangeBox_ atk)
    {
		this.enable = enable;
		this.new_attack = new_attack;
		this.horiz_flip = horiz_flip;
		this.graph_name = graph_name;
		this.remain_time = remain_time;
		this.horiz_flip = horiz_flip;
		this.offset_x = offset_x;
		this.offset_y = offset_y;
		this.hit = hit;
		this.atk = atk;
	}
}


public struct ActionInfo_
{
	public int action_type;
	public LCUI_BOOL replay;
	//public ActionFrameInfo_[DefineConstantsGame_action.MAX_FRAME_NUM] frame;
	public ActionFrameInfo_[] frame;

	public ActionInfo_(int type ,LCUI_BOOL replay_,ActionFrameInfo_[] frame_)
    {
		action_type = type;
		replay = replay_;
		frame = frame_;

	}
}